package com.easy.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.easy.bean.PermissionBean;
import com.easy.bean.RoleBean;
import com.easy.bean.UserBean;
import com.easy.mapper.EasyPermissionMapper;
import com.easy.mapper.EasyRoleMapper;
import com.easy.mapper.EasyUserMapper;

@Service
public class EasyService {
	@Autowired
	EasyUserMapper userM;
	@Autowired
	EasyRoleMapper roleM;
	@Autowired
	EasyPermissionMapper permissionM;

	public UserBean getUserByUsername(String username) {
		QueryWrapper<UserBean> qw = new QueryWrapper<UserBean>();
		qw.eq(true, "username", username);
		UserBean result = userM.selectOne(qw);
		return result;
	}

	public List<RoleBean> getRolesByUserName(String username) {
		List<RoleBean> roles = roleM.getRolesByUsername(username);
		return roles;
	}

	public List<PermissionBean> getPermissionByUserName(String username) {
		List<PermissionBean> permissions = permissionM.getPermissionByUsername(username);
		return permissions;
	}
}
